package com.coincalf.wallet.entity;

import com.baomidou.mybatisplus.enums.IdType;

import java.util.Date;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotations.Version;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * <p>
 * 用户钱包地址信息,即用户充币地址
 * </p>
 *
 * @author crow
 * @since 2018-05-16
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@TableName("user_address")
public class UserAddress extends Model<UserAddress> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 用户ID
     */
    @TableField("user_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    /**
     * 币种ID
     */
    @TableField("coin_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long coinId;

    /**
     * 地址
     */
    private String address;

    /**
     * keystore
     */
    private String keystore;

    /**
     * 私钥
     */
    @TableField("private_key")
    private String privateKey;

    /**
     * 密码
     */
    private String pwd;

    /**
     * 更新时间
     */
    @TableField("last_update_time")
    private Date lastUpdateTime;

    /**
     * 创建时间
     */
    private Date created;

    public UserAddress(Long userId, Long coinId, String address, String keystore, String pwd, String prk) {
        this.userId = userId;
        this.coinId = coinId;
        this.address = address;
        this.keystore = keystore;
        this.pwd = pwd;
        this.privateKey = prk;
        this.created = new Date();
        this.lastUpdateTime = new Date();
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
